import request from '@/utils/request'
import qs from 'qs'

import { jdyadmin,eduservice } from '@/settings'
const jdyedu = '/jdy-edu'
// const jdyedu = ''


/**
 * -----------------------公司分类---------------------------
 */
// 获取公司分类
export function getCompany(data) {
  return request({
    url: `${jdyadmin}/jdyCompany/seleteDepartment`,
    method: 'post',
    data
  })
}

// 新增公司分类
export function addCompany(data) {
  return request({
    url: `${jdyadmin}/jdyCompany/addDepartments`,
    method: 'post',
    data
  })
}

// 更新公司分类
export function updateCompany(data) {
  return request({
    url: `${jdyadmin}/jdyCompany/updateDepartments`,
    method: 'post',
    data
  })
}

// 删除公司分类
export function deleteCompany(id) {
  return request({
    url: `${jdyadmin}/jdyCompany/deleteDepartments/${id}`,
    method: 'delete'
  })
}
/**
 * -----------------------部门信息---------------------------
 */

// 获取部门信息
export function getBumen(data) {
  return request({
    url: `${jdyadmin}/jdyDepartments/seleteDepartment`,
    method: 'post',
    data
  })
}
// 获取部门信息news
export function getBumenNew(data) {
  return request({
    url: `${jdyadmin}/jdyDepartments/seleteCompanyDepartment`,
    method: 'post',
    data
  })
}

// 新增部门信息
export function addBumen(data) {
  return request({
    url: `${jdyadmin}/jdyDepartments/addDepartments`,
    method: 'post',
    data
  })
}

// 更新部门信息
export function updateBumen(data) {
  return request({
    url: `${jdyadmin}/jdyDepartments/updateDepartments`,
    method: 'post',
    data
  })
}

// 删除部门信息
export function deleteBumen(data) {
  return request({
    url: `${jdyadmin}/jdyDepartments/deleteDepartments/${data}`,
    method: 'delete'
  })
}

/**
 * -----------------------用户信息---------------------------
 */
// 获取用户列表信息
export function getUser(data) {
  return request({
    url: `${jdyadmin}/jdyUser/seleteUser`,
    method: 'post',
    data
  })
}

// 新增用户信息
export function addUser(data) {
  return request({
    url: `${jdyadmin}/jdyUser/addUser`,
    method: 'post',
    data
  })
}

// 更新用户信息
export function updateUser(data) {
  return request({
    url: `${jdyadmin}/jdyUser/updateJdyUser`,
    method: 'post',
    data
  })
}

// 删除用户信息
export function deleteUser(data) {
  return request({
    url: `${jdyadmin}/jdyUser/deleteUser/${data}`,
    method: 'delete'
  })
}

/**
 * -----------------------人员档案---------------------------
 */

// 获取人员档案信息
export function getPeople(data) {
  return request({
    url: `${jdyadmin}/jdyUserFile/seletejdyUserfile`,
    method: 'post',
    data
  })
}

// 新增人员档案信息
export function addPeople(data) {
  return request({
    url: `${jdyadmin}/jdyUserFile/addjdyRole`,
    method: 'post',
    data
  })
}

// 更新文件
export function updatePeople(data) {
  return request({
    url: `${jdyadmin}/jdyUserFile/updatejdyRole`,
    method: 'post',
    data
  })
}

// 删除文件
export function deletePeople(data) {
  return request({
    url: `${jdyadmin}/jdyUserFile/deletejdyRole/${data}`,
    method: 'delete'
  })
}

/**
 * -----------------------角色管理---------------------------
 */
// 获取角色信息
export function getRole(data) {
  return request({
    url: `${jdyadmin}/jdyRole/seletejdyRole`,
    method: 'post',
    data
  })
}

// 新增角色信息
export function addRole(data) {
  return request({
    url: `${jdyadmin}/jdyRole/addjdyRole`,
    method: 'post',
    data
  })
}

// 新增角色信息获取id
export function addRoleGetid(data) {
  return request({
    url: `${jdyadmin}/jdyRole/addjdyRoleID`,
    method: 'post',
    data
  })
}

// 更新角色信息
export function updateRole(data) {
  return request({
    url: `${jdyadmin}/jdyRole/updatejdyRole`,
    method: 'post',
    data
  })
}

// 删除角色信息
export function deleteRole(data) {
  return request({
    url: `${jdyadmin}/jdyRole/deletejdyRole/${data}`,
    method: 'delete'
  })
}

/**
 * ---------------------------------------------------
 * --------------------角色对应权限--------------------
 * ---------------------------------------------------
 */
export function getRolePermission(data) {
  return request({
    url: `${jdyadmin}/userRolePermission/seleteUserRolePermission`,
    method: 'post',
    data
  })
}

// 新增角色权限（测试）
export function addRolePermissionCeshi(data) {
  return request({
    url: `${jdyadmin}/userRolePermission/addRolePermission`,
    method: 'post',
    data
  })
}

// 新增角色权限
export function addRolePermission(data) {
  return request({
    url: `${jdyadmin}/userRolePermission/addUserRolePermission`,
    method: 'post',
    data
  })
}

// 更新角色权限
export function updateRolePermission(data) {
  return request({
    url: `${jdyadmin}/userRolePermission/updateUserRolePermission`,
    method: 'post',
    data
  })
}

// 删除角色权限
export function deleteRolePermission(data) {
  return request({
    url: `${jdyadmin}/userRolePermission/deleteUserRolePermission`,
    method: 'post',
    data
  })
}

/**
 * ---------------------------------------------------
 * --------------------用户关联角色 --------------------
 * ---------------------------------------------------
 */
// 根据角色查权限
export function jueseChaQuanxian(data) {
  return request({
    url: `${jdyadmin}/userRole/seleteRolePermission`,
    method: 'post',
    data
  })
}

// 新增用户关联角色
export function xinzengQuanxian(data) {
  return request({
    url: `${jdyadmin}/userRolePermission/addUserRolePermission`,
    method: 'post',
    data
  })
}

// 更新权限信息
export function gengxinQuanxian(data) {
  return request({
    url: `${jdyadmin}/userRole/updateUserRole`,
    method: 'post',
    data
  })
}

// 删除用户关联角色
export function shanchuQuanxian(data) {
  return request({
    url: `/userRolePermission/deleteUserRolePermission/${data}`,
    method: 'delete'
  })
}



/**
 * ---------------------------------------------------
 * ----------------------权限管理---------------------
 * ---------------------------------------------------
 */

export function getUserPermission(data) {
  return request({
    url: `${jdyadmin}/userPermission/seleteUserPermission`,
    method: 'post',
    data
  })
}

// 新增权限
export function addUserPermission(data) {
  return request({
    url: `${jdyadmin}/userPermission/addUserPermission`,
    method: 'post',
    data
  })
}

// 更新权限
export function updateUserPermission(data) {
  return request({
    url: `${jdyadmin}/userPermission/updateUserPermission`,
    method: 'post',
    data
  })
}

// 删除权限
export function deleteUserPermission(id) {
  return request({
    url: `${jdyadmin}/userPermission/deleteUserPermission/${id}`,
    method: 'delete'
  })
}



/**
 * ----------------------文件上传----------------------
 */
export function uploadFile(data,config) {
  return request({
    url: `${jdyadmin}/jdyFileUpload/upload`,
    config,
    method: 'post',
    data
  })
}
//将文件链接上传
export function uploadFilelian(data) {
  return request({
    url: `${jdyadmin}/jdyUserFile/addjdyRole`,
    method: 'post',
    data
  })
}
// 删除文件管理
export function deleteFilelian(id) {
  return request({
    url: `${jdyadmin}/jdyUserFile/deletejdyRole/${id}`,
    method: 'delete',
  })
}
// 更新文件管理
export function updateFilelian(data) {
  return request({
    url: `${jdyadmin}/jdyUserFile/updatejdyRole`,
    method: 'post',
    data
  })
}



/**
 * --------------------根据id查询文件--------------------
 */
export function getUserFiles(data) {
  return request({
    url: `${jdyadmin}/jdyUserFile/seletejdyUserfile`,
    method: 'post',
    data
  })
}

// 用户关联角色操作
export function userContactRole(data) {
  return request({
    url: `${jdyadmin}/userRole/addUserRole`,
    method: 'post',
    data
  })
}


/**
 * ----------------------------------------------------
 * ----------------------视频教程-----------------------
 * ----------------------------------------------------
 */

 /**
 * ----------------------------------------------------
 * --------------------课程章节管理---------------------
 * ----------------------------------------------------
 */

// 新增章节
export function addZhangjie(data) {
  return request({
    url: `${jdyedu}${eduservice}/edu-chapter`,
    method: 'post',
    data
  })
}

// 嵌套章节数据列表
export function qiantaoList(courseId) {
  return request({
    url: `${jdyedu}${eduservice}/edu-chapter/nested-list/${courseId}`,
    method: 'get'
  })
}

// 根据id删除章节
export function deleteZhangjie(id) {
  return request({
    url: `${jdyedu}${eduservice}/edu-chapter/${id}`,
    method: 'DELETE'
  })
}

// 根据id查询章节
export function selectZhangjie(id) {
  return request({
    url: `${jdyedu}${eduservice}/edu-chapter/${id}`,
    method: 'get'
  })
}

// 根据id修改章节
export function updateZhangjie(id,data) {
  return request({
    url: `${jdyedu}${eduservice}/edu-chapter/${id}`,
    method: 'PUT',
    data
  })
}

 /**
 * ----------------------------------------------------
 * --------------------课程描述管理---------------------
 * ----------------------------------------------------
 */
// 根据id查课程描述
export function selectMiaoshu(id) {
  return request({
    url: `${jdyedu}${eduservice}/edu-course/course-info/${id}`,
    method: 'get'
  })
}

// 根据id查课程发布信息描述
export function selectFabu(id) {
  return request({
    url: `${jdyedu}${eduservice}/edu-course/course-publish-info/${id}`,
    method: 'get'
  })
}

// 根据id发布课程信息描述
export function fabuKecheng(id) {
  return request({
    url: `${jdyedu}${eduservice}/edu-course/publish-course/${id}`,
    method: 'get'
  })
}

// 新增课程描述
export function addKecheng(data) {
  return request({
    url: `${jdyedu}${eduservice}/edu-course/save-course-info`,
    method: 'post',
    data
  })
}

// 更新课程描述
export function updateKecheng(data) {
  return request({
    url: `${jdyedu}${eduservice}/edu-course/update-course-info`,
    method: 'post',
    data
  })
}

// 根据id删除课程描述
export function deleteKecheng(id) {
  return request({
    url: `${jdyedu}${eduservice}/edu-course/${id}`,
    method: 'DELETE'
  })
}

// 分页课程列表
export function kechengList(page,limit) {
  return request({
    url: `${jdyedu}${eduservice}/edu-course/${page}/${limit}`,
    method: 'get'
  })
}

/**
 * ----------------------------------------------------
 * --------------------课程分类管理---------------------
 * ----------------------------------------------------
 */
// excel批量导入
export function importFenlei(data) {
  return request({
    url: `${jdyedu}${eduservice}/edu-subject/import`,
    method: 'post',
    data
  })
}

// 新增一级分类
export function addOneClassify(data) {
  return request({
    url: `${jdyedu}${eduservice}/edu-subject/save-level-one`,
    method: 'post',
    data
  })
}

// 新增二级分类
export function addTwoClassify(data) {
  return request({
    url: `${jdyedu}${eduservice}/edu-subject/save-level-two`,
    method: 'post',
    data
  })
}

// 嵌套数据列表
export function threeList(data) {
  return request({
    url: `${jdyedu}${eduservice}/edu-subject/tree`,
    method: 'get'
  })
}


/**
 * ----------------------------------------------------
 * ----------------------讲师管理-----------------------
 * ----------------------------------------------------
 */

 // 所有讲师列表
export function allTeacherList() {
  return request({
    url: `${jdyedu}${eduservice}/teacher`,
    method: 'get'
  })
}

// 新增讲师
export function addTeacher(data) {
  return request({
    url: `${jdyedu}${eduservice}/teacher/addTeacher`,
    method: 'post',
    data
  })
}

// 获取讲师详细信息
export function getTeacherInfo(id) {
  return request({
    url: `${jdyedu}${eduservice}/teacher/getTeacherInfo/${id}`,
    method: 'get'
  })
}

// 获取详细信息
export function getInfo() {
  return request({
    url: `${jdyedu}${eduservice}/teacher/info`,
    method: 'get'
  })
}

// 讲师登录
export function teacherLogin(data) {
  return request({
    url: `${jdyedu}${eduservice}/teacher/login`,
    method: 'post',
    data
  })
}

// 获取更多讲师列表
export function moreTeacherList(page,limt) {
  return request({
    url: `${jdyedu}${eduservice}/teacher/moreConditionPageList/${page}/${limt}`,
    method: 'post'
  })
}

// 获取更多讲师列表2
export function moreTeacherList2(page,limt) {
  return request({
    url: `${jdyedu}${eduservice}/teacher/pageList/{page}/{limt}`,
    method: 'get'
  })
}

// 更新讲师
export function updateTeacher(id,data) {
  return request({
    url: `${jdyedu}${eduservice}/teacher/updateTeacher/${id}`,
    method: 'post',
    data
  })
}

// 删除讲师
export function deleteTeacher(id) {
  return request({
    url: `${jdyedu}${eduservice}/teacher/${id}`,
    method: 'delete'
  })
}


/**
 * ----------------------------------------------------
 * --------------------课程小节管理---------------------
 * ----------------------------------------------------
 */
// 新增课时
export function addClassHour(data) {
  return request({
    url: `${jdyedu}${eduservice}/edu-video/save-video-info`,
    method: 'post',
    data
  })
}

// 更新课时
export function updateClassHour(data) {
  return request({
    url: `${jdyedu}${eduservice}/edu-video/update-video-info`,
    method: 'post',
    data
  })
}

// 上传文件
export function uploadKeshi(data) {
  return request({
    url: `${jdyedu}${eduservice}/edu-video/upload`,
    method: 'post',
    timeout: 60*1000*30,
    data
  })
}

// 根据id查询课时
export function selectKeshi(id) {
  return request({
    url: `${jdyedu}${eduservice}/edu-video/video-info/${id}`,
    method: 'get'
  })
}

// 根据id删除课时
export function deleteKeshi(id) {
  return request({
    url: `${jdyedu}${eduservice}/edu-video/deleteById/${id}`,
    method: 'DELETE'
  })
}

// 根据id删除课时文件
export function deleteKeshiFile(videoId) {
  return request({
    url: `${jdyedu}${eduservice}/edu-video/removeVideo/${videoId}`,
    method: 'DELETE'
  })
}

// 文件上传管理
export function kcFileUpload(data) {
  return request({
    url: `${jdyedu}${eduservice}/oss/upload`,
    method: 'post',
    data
  })
}

// 获取视频播放凭证
export function getPlayauth(vid) {
  return request({
    url: `${jdyedu}${eduservice}/edu-video/getPalyAuth/${vid}`,
    method: 'GET',
  })
}

/**
 * ----------------------------------------------------
 * ----------------------投票系统-----------------------
 * ----------------------------------------------------
 */
const toupiaoApi = 'http://118.24.255.51:9999'
// 投票汇总
export function toupiaoHuizong() {
  return request({
    url: `${toupiaoApi}${jdyedu}/ceshi-toupiao`,
    method: 'get'
  })
}
// 查询作品
export function selectZuopin(data) {
  return request({
    url: `${toupiaoApi}${jdyedu}/ceshi-toupiao-img`,
    method: 'post',
    data
  })
}
// 新增作品
export function addZuopin(data) {
  return request({
    url: `${toupiaoApi}${jdyedu}/ceshi-toupiao-img/save`,
    method: 'post',
    data
  })
}
// 更新作品
export function updateZuopin(data) {
  return request({
    url: `${toupiaoApi}${jdyedu}/ceshi-toupiao-img/updateTeacher`,
    method: 'post',
    data
  })
}
// 删除作品
export function deleteZuopin(id) {
  return request({
    url: `${toupiaoApi}${jdyedu}/ceshi-toupiao-img/${id}`,
    method: 'delete'
  })
}

// 上传图片
export function uploadImg(data) {
  return request({
    url: `${toupiaoApi}${jdyedu}/jdyFileUpload/upload`,
    method: 'post',
    data
  })
}
// 删除图片
export function deleteImg(data) {
  return request({
    url: `${toupiaoApi}${jdyedu}/jdyFileUpload/upload`,
    method: 'post',
    data
  })
}
/**
 * ---------------------
 * ------投票设置--------
 * ---------------------
 */
// 获取投票设置
export function getTpSet(data) {
  return request({
    url: `${toupiaoApi}${jdyedu}/ceshi-toupiao-img-set`,
    method: 'post',
    data
  })
}

// 新增投票设置
export function addTpSet(data) {
  return request({
    url: `${toupiaoApi}${jdyedu}/ceshi-toupiao-img-set/save`,
    method: 'post',
    data
  })
}

// 更新投票设置
export function updateTpSet(data) {
  return request({
    url: `${toupiaoApi}${jdyedu}/ceshi-toupiao-img-set/updateTeacher`,
    method: 'post',
    data
  })
}

// 删除投票设置
export function deleteTpSet(id) {
  return request({
    url: `${toupiaoApi}${jdyedu}/ceshi-toupiao-img-set/${id}`,
    method: 'delete'
  })
}







// const ceshiapi = 'http://192.168.66.224:8101'
const ceshiapi = 'http://118.24.255.51:9999/'
/**
 * ----------------------------------------------------
 * ----------------------问题测试-----------------------
 * ----------------------------------------------------
 */
// 获取问题测试
export function getPeoblemTest(data) {
  return request({
    url: `${ceshiapi}${jdyedu}/edu-chapter-test/getEduChapterTest`,
    method: 'post',
    data
  })
}

// 新增问题测试
export function addPeoblemTest(data) {
  return request({
    url: `${ceshiapi}${jdyedu}/edu-chapter-test/addEduChapterTest`,
    method: 'post',
    data
  })
}

// 更新问题测试
export function updatePeoblemTest(data) {
  return request({
    url: `${ceshiapi}${jdyedu}/edu-chapter-test/updateTeacher`,
    method: 'post',
    data
  })
}

// 删除问题测试
export function deletePeoblemTest(id) {
  return request({
    url: `${ceshiapi}${jdyedu}/edu-chapter-test/${id}`,
    method: 'DELETE'
  })
}


/**
 * ----------------------------------------------------
 * --------------------问题测试结果---------------------
 * ----------------------------------------------------
 */
// 获取问题测试结果
export function getPeoblemTestResult(data) {
  return request({
    url: `${ceshiapi}${jdyedu}/edu-chapter-test-result/getEduChapterTest`,
    method: 'post',
    data
  })
}

// 新增问题测试结果
export function addPeoblemTestResult(data) {
  return request({
    url: `${ceshiapi}${jdyedu}/edu-chapter-test-result/addEduChapterTest`,
    method: 'post',
    data
  })
}

// 更新问题测试结果
export function updatePeoblemTestResult(data) {
  return request({
    url: `${ceshiapi}${jdyedu}/edu-chapter-test-result/updateTeacher`,
    method: 'post',
    data
  })
}

// 删除问题测试结果
export function deletePeoblemTestResult(id) {
  return request({
    url: `${ceshiapi}${jdyedu}/edu-chapter-test-result/${id}`,
    method: 'DELETE'
  })
}